﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Nhandang
{
    public class Layer : List<Neuron>
    {
        public Layer(int size)
        {
            for (int i = 0; i < size; i++)
                base.Add(new Neuron());
        }
        public Layer(int size, Layer layer, Random rnd)
        {
            for (int i = 0; i < size; i++)
                base.Add(new Neuron(layer, rnd));
        }
        public Layer(int size, Layer layer, string WeightsFile)
        {
            StreamReader file = File.OpenText(WeightsFile);
            for (int i = 0; i < size; i++)
            {
                double[] arrWvalue = GetWeights(file.ReadLine());
                base.Add(new Neuron(layer, arrWvalue));
            }
            file.Close();
        }
        private double[] GetWeights(string line)
        {
            string[] arrW;
            arrW = line.Split(',');
            double[] arrWvalue = new double[arrW.Length];
            for (int i = 0; i < arrW.Length; i++)
                arrWvalue[i] = Convert.ToDouble(arrW[i].Trim());
            return arrWvalue;
        }
    }
}
